package models

import (
	"github.com/revel/revel"
	"uc/app/db"
	"github.com/astaxie/beego/logs"
	"os"
)

var Log *logs.BeeLogger

func Init() {
	host = revel.Config.StringDefault("mail.host", "smtp.163.com")
	port = revel.Config.IntDefault("mail.port", 25)
	user = revel.Config.StringDefault("mail.usr", "songkemail@163.com")
	pwd = revel.Config.StringDefault("mail.pwd", "songke198916")
	suject = revel.Config.StringDefault("mail.subject", "验证码")
	//TODO:
	//revel.INFO.Println("-------------->template:",template)
	//template = revel.Config.StringDefault("sms.template", "【蓝视科技】你好，你的验证码是：%s")
	//revel.INFO.Println("-------------->template:",template)
	url = revel.Config.StringDefault("sms.url", "http://183.57.76.50:8080/sms/sendsms")
	smsusr = revel.Config.StringDefault("sms.usr", "yanzmfx")
	smspwd = revel.Config.StringDefault("sms.pwd", "yanzmfx")

	db.InitMysql(revel.Config.StringDefault("mysql", "root:123456@tcp(192.168.59.103:3306)/uc"))
	db.InitRedis(revel.Config.StringDefault("redis", "192.168.0.100:6379"))
	
	Log = logs.NewLogger(10000)
	Log.SetLogger("console", "")
	Log.EnableFuncCallDepth(true)
	os.MkdirAll("c:/logs/uc", os.ModeDir)
	Log.SetLogger("file", `{"filename":"` + "c:/logs/uc/uc.log" +`"}`)
	Log.SetLogger("smtp", `{"level":3,"subject":"uc","fromAddress":"songkemail@163.com","username":"songkemail@163.com","password":"songke198916","host":"smtp.163.com:25","sendTos":["553403792@qq.com"]}`)
}


